package com.forevershine.business.persistent.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.forevershine.business.model.Task;
import com.forevershine.business.persistent.IDataAccessor;
import com.forevershine.business.persistent.TaskDao;


public class TaskDaoImpl implements TaskDao {

	@Override
	public List<Task> loadTaskList(IDataAccessor dataAccessor, int userId) {
		 SqlSession session = dataAccessor.getSession();
		 List<Task> list = (List<Task>) session.selectList("selectTasks",userId);
		 for(Task task : list)
		 {
			
		 }
		 session.close();
		 return list;
	}

	@Override
	public Task insertTask(IDataAccessor dataAccessor, Task task) {
		SqlSession session = dataAccessor.getSession();
		session.insert("insertTask", task);
		session.commit();
		// we can control the commit by return the session.
		return task;
	}

}
